package com.cskaoyan.dbutils.rsh;

import com.cskaoyan.connectionpool.opensource.DruidUtils;
import org.apache.commons.dbutils.QueryRunner;
import org.apache.commons.dbutils.handlers.ColumnListHandler;

import java.sql.SQLException;
import java.util.List;

/**
 * 创建日期: 2022/08/29 11:18
 *
 * @author ciggar
 */
public class ColumnListHandlerDemo {


    public static void main(String[] args) throws SQLException {


        // 1. 构建QueryRunner
        QueryRunner queryRunner = new QueryRunner(DruidUtils.getDataSource());

        // 2. 执行SQL语句
        List<String> nameList = queryRunner.query("select username from user",new ColumnListHandler<>());

        // 3. 打印
        System.out.println(nameList);
    }
}
